package org.drools.examples.banking;

import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

public class BankingExample5 {    
    public static final void main(final String[] args) {         
        KieServices ks = KieServices.Factory.get();
        KieContainer kc = ks.getKieClasspathContainer();
        execute( kc );
    }
    public static void execute( KieContainer kc ) {
        KieSession ksession = kc.newKieSession("BankingExample5KS");  
        Object[] cashflows = {
                new TypedCashflow(new SimpleDate("01/01/2007"),    
                                  TypedCashflow.CREDIT, 300.00),
                new TypedCashflow(new SimpleDate("05/01/2007"),
                                  TypedCashflow.CREDIT, 100.00),
                new TypedCashflow(new SimpleDate("11/01/2007"),
                                  TypedCashflow.CREDIT, 500.00),
                new TypedCashflow(new SimpleDate("07/01/2007"),
                                  TypedCashflow.DEBIT, 800.00),
                new TypedCashflow(new SimpleDate("02/01/2007"),
                                  TypedCashflow.DEBIT, 400.00),
            };
        
        for ( int i = 0; i < cashflows.length; i++ ) {
            Object fact = cashflows[i];
            System.out.println( "Inserting fact: " + fact );
            ksession.insert( fact );
        }        
               
        ksession.fireAllRules();
        ksession.dispose();
    }
}
